import { createSlice } from '@reduxjs/toolkit'
import dayjs from 'dayjs'

export const dateSlice = createSlice({
  name: 'date',
  initialState: {
    date:dayjs().format('MM-DD')
  },
  reducers: {
    delDate(state,{payload}){
      state.date=dayjs(state.date).subtract(1,'day').format('MM-DD')
    },
    addDate(state,{payload}){
      state.date=dayjs(state.date).add(1,'day').format('MM-DD')
    }
  },
})

// Action creators are generated for each case reducer function
export const { delDate,addDate } = dateSlice.actions

export default dateSlice.reducer